import CLRequest from '../index'
import { IAccount, IDataType, ILoginResult } from './type'

enum LoginAPI {
  AccountLogin = 'login',
  LoginUserInfo = 'users/',
  UserMenus = 'role/'
}

//用户登陆
export function accountLoginAction(account: IAccount) {
  return CLRequest.post<IDataType<ILoginResult>>({
    url: LoginAPI.AccountLogin,
    data: account
  })
}

//查询用户详情
export function requestUserInfoById(id: number) {
  return CLRequest.get<IDataType>({
    url: LoginAPI.LoginUserInfo + id
  })
}

//用户权限菜单
export function requestUserMenusByRoleId(id: number) {
  return CLRequest.get<IDataType>({
    url: LoginAPI.UserMenus + id + '/menu'
  })
}
